<template>
  <music-list :title="title" :bgImg="bgImg" :songs="songs"></music-list>
</template>

<script>
  import {mapGetters} from 'vuex';
  import MusicList from '../music-list/music-list.vue';
  import {getSongListFromDisc} from 'api/recommend.js';
  import {ERR_OK} from 'api/config.js';
  export default {
    components: {MusicList},
    data () {
      return {
        songs: []
      };
    },
    computed: {
      title () {
        return this.disc.dissname;
      },
      bgImg () {
        return this.disc.imgurl;
      },
      ...mapGetters([
        'disc'
      ])
    },
    methods: {
      _getSongList () {
        getSongListFromDisc(this.disc.dissid).then(res => {
          if (res.code === ERR_OK) {
            const ret = res.cdlist[0];
            this.songs = ret.songlist || [];
          }
        }).catch(() => {
          console.log(`get disc songlist error`);
        });
      }
    },
    created () {
      this._getSongList();
    }
  };
</script>

<style>

</style>
